//----------------------------------------------------------------------------
// main.cpp
//
// main for swine
//
// Copyright (C) 2011 Neil Butterworth
//----------------------------------------------------------------------------

#include <windows.h>
#include <iostream>
#include <string>

#include "cmdline.h"
#include "error.h"
#include "command.h"

using namespace std;
using namespace Swine;

int main( int argc, char * argv[] ) {

	try {
		CmdLine cl( argc, argv );
		if ( cl.Argc() == 1 ) {
			cl.Append( "help" );
		}

		const Command * cmd = CommandDict::Instance().Find( cl.Argv(1) );
		if ( cmd == 0 ) {
			throw Error( "Invalid command: " + cl.Argv(1) );
		}
		int rv = cmd->Execute( cl );

		return rv;
	}
	catch( const Error & e ) {
		cerr << e.what() << endl;
		return 1;
	}

}

